<?php

namespace App\Listeners\Reply;

use App\Events\Reply\CreateReplyEvent;
use App\Listeners\BaseListener;

class CreateReplyListener extends BaseListener
{
    /**
     * Handle the event.
     *
     * @param CreateReplyEvent $event
     * @return bool
     */
    public function handle(CreateReplyEvent $event)
    {
        $this->saveFileLog(__CLASS__, $event);

        $reply = $event->reply;

        // 队列修改【评论】是否为主体发布者发布
        service()->CommentService->changeHaveAuthorReplyByQueue([
            'comment_id' => $reply['comment_id'],
            'user_id' => $reply['user_id'],
            'target_id' => $reply['target_id'],
            'target_type' => $reply['target_type']
        ]);

        // 队列记录消息
        service()->MessageService->saveAndStaticCommentMessage($event->replyMessageLoadData);

        // 队列记录日志
        service()->LogCountService->createLogByQueue($event->logCountLoadData);

        return true;
    }
}
